﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using aucn.web.au.code;
using System.Collections.Generic;

namespace aucn.web.au.joint
{
    public partial class Detail : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Master.Attributes["submenu"] = "Postgrad";
            string d = Request.QueryString["d"];
           // string p = Request.QueryString["p"];

            if (d!=null)
            {
                JointDepartment jd = JointDepartment.FromXml(d.ToUpper());
                this.Title = jd.DepartmentName;
                List<JointDepartment> jdList = new List<JointDepartment>();
                jdList.Add(jd);
                FormView1.DataBound += new EventHandler(FormView1_DataBound);
                FormView1.DataSource = jdList;
                FormView1.DataBind();
            }
            else
            {
                PageBase.RaiseError("Invalid parameter");
            }
        }

        void FormView1_DataBound(object sender, EventArgs e)
        {
            JointDepartment jd = (JointDepartment)FormView1.DataItem;

            Repeater rptrProgram = (Repeater)FormView1.Row.FindControl("rptrProgram");
            rptrProgram.ItemDataBound += new RepeaterItemEventHandler(Repeater1_ItemDataBound);

            rptrProgram.DataSource = jd.ProgramList;
            rptrProgram.DataBind();
        }


        void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Repeater rptUniversity = (Repeater)e.Item.FindControl("rptrUniversity");
            JointProgram u = (JointProgram)e.Item.DataItem;
            rptUniversity.ItemDataBound += new RepeaterItemEventHandler(rptUniversity_ItemDataBound);
            rptUniversity.DataSource = u.UniversityList;
            rptUniversity.DataBind();
        }

        void rptUniversity_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Repeater rptSubjects = (Repeater)e.Item.FindControl("rptrSubjects");
            JointUniversity ju = (JointUniversity)e.Item.DataItem;
            rptSubjects.DataSource = ju.SubjectList;
            rptSubjects.DataBind();
        }
    }
}
